sincos

This function is a sum of sines and cosines of the form:

f (x) = a0 + aisinai+1x + ai+2cosai+3x.

You need good initial guess to get this fitting function to converge quickly, if at all. You will do well to get the frequencies close. If the zeros of your fitting function with your initial parameters are close to the zeroes of your data, you have a good chance of converging. For special cases like Fourier series, you probably want a specialized function. You should take a Fourier transform if that is what you really want.